<% if @available_compliance_classes.present? %>
  <%= section_panel 'New Compliance', :width => 'double', :position => 'left' do %>
    <div class="form-horizontal">
      <div class="ciAttributes">
        <div class="category">
          <div class="name">Select Compliance Type</div>
          <div class="control-group">
            <%= label_tag :compliance_class, 'Compliance Type', :class => 'control-label' %>
            <div class="controls">
              <%= select_tag(:compliance_class,
                             options_for_select(@available_compliance_classes.map {|c| [c.description.presence || c.className, c.className]}),
                             :id       => 'compliance_class_select',
                             :required => true) %>
            </div>
          </div>
          <script type="text/javascript">
            $j("#compliance_class_select").on("change", function () {
              $j("#new_compliance_details").html('<%= escape_javascript(loading_indicator) %>');
              $j.ajax({url: "<%= new_cloud_compliance_path(@cloud) %>", data: {compliance_class: this.value}});
            });
          </script>
        </div>
      </div>
    </div>
    <hr/>
    <div id="new_compliance_details">
      <% if @compliance %>
        <%= render 'base/shared/edit_form',
                   {:resource   => @compliance,
                    :content    => 'cms/cis/ci',
                    :remote     => true,
                    :form_url   => cloud_compliances_path(@cloud),
                    :cancel_url => cloud_compliances_path(@cloud)} %>

      <% end %>
    </div>
  <% end %>
<% else %>
  All available compliance types have been already added.
<% end %>
